﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tommy
{
    public class EventTable
    {
        public delegate bool _event_predifined(ref Context context);

        
        #region system event
        public static event _event_predifined event_loader_initializing;
        public static event _event_predifined event_loader_initialize;
        public static event _event_predifined event_loader_initialized;

        public static event _event_predifined event_loader_showing;
        public static event _event_predifined event_loader_show;
        public static event _event_predifined event_loader_shown;

        public static event _event_predifined event_plugins_initializing;
        public static event _event_predifined event_plugins_initialize;
        public static event _event_predifined event_plugins_initialized;

        public static event _event_predifined event_user_login;
        
        #region related with default Browser
        public static event _event_predifined event_browser_initializing;
        public static event _event_predifined event_browser_initialize;
        public static event _event_predifined event_browser_initialized;
        public static event _event_predifined event_browser_showing;
        public static event _event_predifined event_browser_show;
        public static event _event_predifined event_browser_shown;
        
         #endregion
        
        #region related with Navigator of the Browser
        public static event _event_predifined event_browser_navagator_initializing;
        public static event _event_predifined event_browser_navagator_initialize;
        public static event _event_predifined event_browser_navagator_initialized;

        public static event _event_predifined event_browser_navagator_showing;
        public static event _event_predifined event_browser_navagator_show;
        public static event _event_predifined event_browser_navagator_shown;
        #endregion

        #region related with menu bar of the Browser    
        public static event _event_predifined event_browser_menubar_initializing;
        public static event _event_predifined event_browser_menubar_initialize;
        public static event _event_predifined event_browser_menubar_initialized;

        public static event _event_predifined event_browser_menubar_showing;
        public static event _event_predifined event_browser_menubar_show;
        public static event _event_predifined event_browser_menubar_shown;
        #endregion



        #endregion

        private static List< _event_predifined> acts = new List< _event_predifined>();
        public static void InitActs()
        {
            acts.Clear();
            acts.Add(event_loader_initializing);
            acts.Add(event_loader_initialize);
            acts.Add(event_loader_initialized);
            
            
            acts.Add(event_browser_initializing);
            acts.Add(event_browser_initialize);
            acts.Add(event_browser_initialized); 
            
            acts.Add(event_browser_navagator_initializing);
            acts.Add(event_browser_navagator_initialize);
            acts.Add(event_browser_navagator_initialized);


            acts.Add(event_browser_menubar_initializing);
            acts.Add(event_browser_menubar_initialize);
            acts.Add(event_browser_menubar_initialized);

            acts.Add(event_loader_showing);
            acts.Add(event_loader_show);
            acts.Add(event_loader_shown);

            acts.Add(event_browser_showing);
            acts.Add(event_browser_show);
            acts.Add(event_browser_shown);
        }

        public static bool Act(ref Context context)
        {
            foreach (_event_predifined e in acts )
            {
                if (e != null)
                    e(ref context);
            }
            return true;
        }
    }

    
}
